{% extends "header.html" %}

{% block title %}
	Devices
{% endblock %}

{% block page_content %}
	<div class="page-header">
		<h3 class="h3">
			List of Devices connected : 
		</h3>
	</div>
	<div class="table-responsive">
		<table class="table table-hover">
			{% if resp %}
				{% for line_count in range(resp.__len__()) %}
				<tr>
					<td class="click-dropdown-field">
						<div class="header">
							<strong>
								<span class="device-number">
									Device {{line_count + 1}} :
								</span>

								<span class="device-address">
									{% set network_addr = resp[line_count].networkAddresses.split(" ") %}
									{% if network_addr[0] == "0.0.0.0" %}
										Network Address : {{network_addr[1]}}
									{% else %}
										Network Address : {{network_addr[0]}}
									{% endif %}
								</span>
							</strong>
						</div>

						<div class="content">
							Switch Datapath Id : {{resp[line_count].switch_dpid}}
							<br/>
							Hardware Address : {{resp[line_count].dataLayerAddress}}
							<br/>
							Port Number : {{resp[line_count].port}}
						</div>
					</td>
				</tr>
				{% endfor %}
			{% endif %}
		</table>
	</div>
	{{data}}
{% endblock %}

{% block scripts %}
	{{ super() }}
	<script type="text/javascript" src="{{url_for('static', filename='js/devices.js')}}"></script>
	<script type="text/javascript">
		setInterval(function(){
			$('.table-responsive').load(document.URL +  ' .table-responsive');
		}, 5000);
	</script>
{% endblock %}